#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "uart_init.h"

void rfid_card_print(char *rfid, int length)
{
	int i;
	
	printf("rfid card number:\n\t");
	for(i=0;i<length;i++)
	{
		printf("0x%02x ", rfid[i]);
	}
	printf("\n");
}

void rfid_card_read(int uart_fd, char *rfid, int length)
{
	int i;
	
	for(i=0;i<length;i++)
	{
		read(uart_fd, rfid+i, 1);
	}
}

int main(int argc, char *argv[])
{
	int uart_fd;
	
	uart_fd = uart_init("/dev/ttyUSB0");
	printf("%d\n", uart_fd);
	while(1)
	{
		char rfid[5] = "";
		
		rfid_card_read(uart_fd, rfid, sizeof(rfid));
		rfid_card_print(rfid, sizeof(rfid));
	}
	uart_uninit(uart_fd);
	
	return 0;
}
